/**
 * Created with CLion.
 * Description: 
 * User: loong
 * Date: 2019-10-12
 * Time: 14:45
 */
#ifndef VOICEROBOT_DBHEAPER_H
#define VOICEROBOT_DBHEAPER_H

#include <mysql/mysql.h>
#include <string.h>
#include <stdio.h>


int insertAll(char *IFLYinfo ,char *TULINGInfo,char *time){
    MYSQL *conn;

    char *server = "101.200.148.140";
    char *user = "loong";
    char *password = "1";
    char *database = "voicerobot";
    conn = mysql_init(NULL);

    char sql[1000];

    memset(sql,0, sizeof(sql));
    sprintf(sql,"%s%s%s%s%s%s%s","insert into voicerobot.voice(ifly_info,tuling_info,time) VALUES(' ",IFLYinfo," ',' " ,TULINGInfo," ',' ",time," ');");


    if (!mysql_real_connect(conn,server,user,password,database,0,NULL,0)){
        fprintf(stderr,"%s\r",mysql_error(conn));
        return -1;
    }
    //将编码设置为utf8
    mysql_query(conn,"set names utf8");

    if (mysql_query(conn,sql)){
        fprintf(stderr,"%s\n",mysql_error(conn));
        return -1;
    }

    mysql_close(conn);
    return 0;
}
#endif //VOICEROBOT_DBHEAPER_H
